<template>
  <div class="page-body">
    <div class="page-head">
      <div @click="utils.toBack()" class="iconfont icon-fanhui"></div>
    </div>
    <div class="page-item-2">
      <div class="tabs">
        <div class="tab">收银记录</div>
      </div>

      <div @click="tuikuanPopupRef.open()" class="initiate-bt">发起退款</div>
    </div>
    <div class="page-content">
      <div class="search-box">
        <div style="width: 300rpx">
          <uni-datetime-picker
            v-model="queryParams.date"
            type="daterange"
          />
        </div>
        <div class="m-l-10" style="width: 220rpx">
          <w-select
            style="width: 100%"
            v-model="queryParams.phone"
            placeholder="请选择交易类型"
            width="100%"
            height="40rpx"
            :list="typeList"
            @change="changeMerchantId"
          />
        </div>

        <div class="m-l-10" style="width: 220rpx">
          <up-input
            style="height: 40rpx"
            v-model="queryParams.phone"
            placeholder="请输入会员手机号"
            maxlength="11"
            type="number"
          ></up-input>
        </div>

        <div class="m-l-10" style="width: 220rpx">
          <up-input
            style="height: 40rpx"
            v-model="queryParams.phone"
            placeholder="请输入会员手机号"
            maxlength="11"
            type="number"
          ></up-input>
        </div>

        <div class="m-l-10" style="width: 220rpx">
          <up-input
            style="height: 40rpx"
            v-model="queryParams.orderNo"
            placeholder="请输入订单编号"
          ></up-input>
        </div>
        <div class="bts flex items-center">
          <div class="search-bt  search-bt-primary">查询</div>
          <div @click="resetQueryParams" class="search-bt">重置</div>
          <!-- <div class="search-bt"></div>
          <div class="search-bt">重置</div> -->
        </div>
      </div>

      <div class="m-t-14">
        <w-table :columns="columns" :data="tableData">
          <template #date="scoped">
            <div>{{ scoped.row }}</div>
          </template>
          <template #operate>
            <div class="flex justify-center">
              <div class="color-primary p-x-5">查看</div>
            </div>
          </template>
        </w-table>
      </div>
    </div>
  </div>

  <tuikuan-popup ref="tuikuanPopupRef" />
</template>
<script setup>

import { ref } from "vue";
import utils from "@/utils/index";
import tuikuanPopup from "./components/tuikuan-popup.vue";
const typeList = ref([
  { name: "门店销售", id: 1 },
  { name: "原单冲账", id: 2 },
  { name: "销售退货", id: 3 },
]);
const queryParams = ref({
  type: undefined,
  date: undefined,
  startTime: new Date("2023-01-01"),
  endTime: new Date("2023-01-31"),
  phone: undefined,
  orderNo: undefined,
});

const columns = ref([
  { title: "交易时间", key: "date" ,width: 2},
  { title: "订单编号", key: "id" },
  { title: "交易类型", key: "id" },
  { title: "金额(元)", key: "id" },
  { title: "会员手机号", key: "id" },
  { title: "收银员", key: "id" },
  { title: "操作", key: "operate" },
]);

const tableData = ref([
  {
    id: "123",
  },
  {
    id: "123",
  },
  {
    id: "123",
  },
  {
    id: "123",
  },
  {
    id: "123",
  },
  {
    id: "123",
  },
  {
    id: "123",
  },
  {
    id: "123",
  },
  {
    id: "123",
  },
  {
    id: "123",
  },
]);
const tuikuanPopupRef = ref()



function resetQueryParams() {
  queryParams.value = {
    type: undefined,
    startTime: new Date("2023-01-01"),
    endTime: new Date("2023-01-31"),
    phone: undefined,
    orderNo: undefined,
  };
}

</script>
<style lang="scss" scoped>
.page-body {
  background: #f0f2f5;
  display: flex;
  flex-direction: column;
  height: 100vh;
}

.page-head {
  display: flex;
  align-items: center;
  height: 50rpx;
  background: rgba(27, 122, 254, 1);
  box-shadow: 0px 0px 13.33px rgba(0, 0, 0, 0.1);
  color: $uni-text-color-inverse;

  .icon-fanhui {
    font-size: 24rpx;
    font-weight: 700;
    width: 60rpx;
    height: 50rpx;
    line-height: 50rpx;
    text-align: center;
    background: rgba(13, 84, 184, 1);
  }
}

.page-item-2 {
  margin-top: 10rpx;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 30rpx 0 60rpx;
  .tabs {
    display: flex;
    align-items: center;
    .tab {
      position: relative;
      color: $uni-color-primary;
      padding: 10rpx;
      width: 90rpx;
      margin-right: 10rpx;
      &::after {
        content: "";
        position: absolute;
        left: 50%;
        bottom: 0;
        transform: translateX(-50%);
        height: 3rpx;
        background: $uni-color-primary;
        width: 90rpx;
      }
    }
  }

  .initiate-bt {
    width: 100rpx;
    height: 40rpx;
    border-radius: 8rpx;
    background: $uni-color-primary;
    line-height: 40rpx;
    text-align: center;
    color: $uni-text-color-inverse;
  }
}

.page-content {
  flex: 1;
  height: 0;
  margin: 10rpx;
  background: $uni-bg-color;
  border-radius: 8rpx;
  padding: 14rpx 20rpx;

  .search-box {
    display: flex;
    align-items: center;
    .search-bt {
      margin-left: 10rpx;
      width: 80rpx;
      height: 40rpx;
      line-height: 40rpx;
      text-align: center;
      border-radius: 4rpx;
      border: 1rpx solid $uni-border-color-1;
    }
    .search-bt-primary {
      color: $uni-color-primary;
      border: 1rpx solid $uni-color-primary;
    }
  }

  // .date-select-box {
  //   display: flex;
  //   align-items: center;
  //   justify-content: center;
  //   border: 1px solid $uni-border-color-1;
  //   height: 40rpx;
  //   line-height: 40rpx;
  //   color: $uni-text-color-2;
  //   border-radius: 4rpx;
  //   .icon-rili {
  //     font-size: 20rpx;
  //     width: 24rpx;
  //     height: 24rpx;
  //     line-height: 24rpx;
  //     text-align: center;
  //   }
  // }
}
</style>
